package com.cloudlead.shipownerAction.action;
import com.cloudlead.common.lang.annotation.Label;
import com.cloudlead.common.lang.persistence.EasyuiGridData;
import com.cloudlead.common.worker.action.impl.AbstractActionFactory;
import com.cloudlead.common.worker.annotation.Action;
import com.cloudlead.common.worker.annotation.Order;
import com.cloudlead.shipownerAction.BusinessModules;
import com.cloudlead.shipownerAction.service.BaseVoyageEditSer;
import com.cloudlead.shipownerService.BaseVoyageEditService;
import com.cloudlead.shipownerService.vo.BaseVoyageCreateVo;
import com.cloudlead.shipownerService.vo.BaseVoyageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.validation.constraints.NotNull;

/**
 * Created by Jinnoo on 2015/8/12.
 */
@Controller
public class BaseVoyageEditActionFactory extends AbstractActionFactory implements BaseVoyageEditService {

    @Autowired//必须要的
            BaseVoyageEditSer baseVoyageSer;

    public BaseVoyageEditActionFactory() {super(BusinessModules.BaseVoyageEdit);}

    @Action
    @Order(1)
    @Label("航次创建")
    public String createVoyage(@Label("基本信息")BaseVoyageCreateVo vo) {
        baseVoyageSer.createVoyage(vo);
        return "OK";
    }

    @Action
    @Order(2)
    @Label("航次编辑")
    public void editVoyage(@Label("基本信息")BaseVoyageVo vo) {
        baseVoyageSer.editVoyage(vo);
    }

    @Action
    @Order(3)
    @Label("单值查询")
    public Object findOneVoyage(@Label("基本信息")BaseVoyageVo vo) {
        return baseVoyageSer.findOneVoyage(vo);
    }

    @Action
    @Order(4)
    @Label("多值查询")
    public EasyuiGridData findAllVoyage(@NotNull @Label("基本信息")BaseVoyageVo bv,@Label("每页条数")int rows ,@Label("页码")int page) {
        return new EasyuiGridData(baseVoyageSer.findAllVoyage(bv,rows,page),"id," +
                "arriveExpectedTime,arriveTime,startExpectedTime,startTime," +
                "state,voyage,vessel,baseShip.id baseShip,baseCompany.companyName shipOwnerName");
    }

    @Action
    @Order(5)
    @Label("航次删除")
    public void delVoyage(@Label("航次ID")String id) {
        baseVoyageSer.delVoyage(id);
    }

}
